<template>
  <div class="risk app-container">
    <div class="mb-20">
      <el-form  v-show="showSearch" :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
        <el-form-item label="用户ID"  prop="memberId"> 
          <el-input v-model="queryParams.memberId" placeholder="请输入用户ID" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item label="任务ID"  prop="taskId">
          <el-input v-model="queryParams.taskId" placeholder="请输入任务ID" clearable @keyup.enter.native="handleQuery" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>
      <right-toolbar class="mb8" :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </div>

    <el-table v-loading="loading" :data="list" style="width: 100%;">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
        </template>
      </el-table-column>
      <el-table-column label="用户ID" align="center" prop="memberId" />
      <el-table-column label="任务ID" align="center" prop="taskId" />
      <el-table-column label="手机号" align="center" prop="memberVO" >
        <template slot-scope="scope">
          <span>{{ scope.row.memberVO.phone }}</span>
        </template>
      </el-table-column>
      <el-table-column label="奖励数量" align="center" prop="num" />
      <el-table-column label="领取时间" align="center" prop="createTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createDate) }}</span>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"  @pagination="getList"/>
  </div>
</template>
<script>
import { getQueryReceiveHistory } from "@/api/system/rewards";

export default {
  name: "rewardsList",
  data() {
    return {
      // 表单参数
      form: {},
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      title: '',
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        memberId: undefined,
        taskId: undefined,
      },
      // 显示搜索条件
      showSearch: true,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true;
      getQueryReceiveHistory(this.queryParams).then(response => {
        this.list = response.data.list;
        this.total = response.data.total || 0;
        this.loading = false;
      });
    },


    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },


  }
};
</script>
